package com.whjfxx.terminal.config;

import com.whjfxx.terminal.interceptor.SecureInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created by b.c on 2022/4/8 11:07
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    final String[] patterns = {
            "/**/*.json",
            "/**/*.html",
            "/**/*.png",
            "/**/*.jpg",
            "/**/*.js",
            "/**/*.css",
            "/**/*.woff",
            "/**/*.ico",
            "/**/*.woff2",
            "/**/*.ttf",
            "/login",
            "/user/add",
            "/file/**",
            "/terminal/**",
            "/captcha/*"
    };

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(new SecureInterceptor());
        registration.addPathPatterns("/**");
        registration.excludePathPatterns(patterns);
    }
}
